import QtQuick 1.1
import com.nokia.meego 1.0
import "Logic.js" as Logic

PageStackWindow {
    id: appWindow

    showStatusBar: screen.orientationString == "Landscape" || screen.orientationString == "LandscapeInverted" ? false : true

    UserTheme { id: userTheme }

    function checkFile( __file ) {
        return cppMeeWords.checkFile( __file )
    }

    //initialPage: mainPage
    initialPage: splashPage

    /* набор параметров на процесс обучения */
    property string learnWord: "word"
    property string learnTranslation: "translation"
    property int answTrue: 0
    property int answFalse: 0
    property variant bufWords
    property int siz_bufWords:0
    property int porgressLearn: 0
    property int curShowTrue: 0
    property int curShowFalse: 0
    property int curWordId: 0
    /*--------------------------------------------------*/
    property variant bufWordsErrorTest
    /*--------------------------------------------------*/

    property variant filterWords: []
    property variant filterWords_indx: []

    function initTableDB() {
        var db = Logic.getDatabase()
        console.log("initTableDB()")
        db.transaction( function(tx) {
                           //tx.executeSql("drop table categories")
                           //tx.executeSql("drop table words")
                           tx.executeSql( "CREATE TABLE IF NOT EXISTS categories ('id' INTEGER UNIQUE PRIMARY KEY AUTOINCREMENT NOT NULL, category TEXT, description TEXT )" )
                           tx.executeSql( "CREATE TABLE IF NOT EXISTS words ('id' INTEGER UNIQUE PRIMARY KEY AUTOINCREMENT NOT NULL, word TEXT, translation TEXT, show_true INTEGER, show_false INTEGER, category_id INTEGER REFERENCES categories ('id') ON DELETE CASCADE ON UPDATE CASCADE )" )
                       }
                    )
    }

    MainPage { id: mainPage }
    Splash { id: splashPage }

    Component.onCompleted: {
        initTableDB()
    }
}
